package fileOprs;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class FileFolder {
	private final String FOLDER = "+";
	private final String FILE = "-";
	private File curFolder;
	private StringBuffer fileOp= new StringBuffer(500);
	
	public void readFolder(File curFolder, int depth) {
			for (int i = 0; i < depth; i++) {
				System.out.print(FOLDER);
				fileOp.append(FOLDER);
			}
			System.out.println(curFolder.getName());
			fileOp.append(curFolder.getName()+"\n");
			File[] child = curFolder.listFiles();
			for (File file : child) {
				if (file.isDirectory()) {
					readFolder(file, depth + 4);
				} else {
					for (int j = 0; j < depth; j++) {
						//System.out.print(FILE);
						//fileOp.append(FILE);
					}
					System.out.println(file.getName());
					fileOp.append(file.getName()+"\n");
				}
			}
	}
	public boolean writeToFile(File opFile){
		boolean success=false;

		try {
			FileWriter fw= new FileWriter(opFile);
			fw.write("Folder Content Details...");
			fw.write(getFileOp().toString());
			success=true;
		} catch (IOException e) {
			System.out.println("IOException ...");
			success=false;
		}
		return success;
	
	}

	public StringBuffer getFileOp() {
		return fileOp;
	}
	public void setFileOp(StringBuffer fileOp) {
		this.fileOp = fileOp;
	}

	public File getCurFolder() {
		return curFolder;
	}

	public void setCurFolder(File curFolder) {
		this.curFolder = curFolder;
	}

	public String getFOLDER() {
		return FOLDER;
	}

	public String getFILE() {
		return FILE;
	}

}
